import {Directive, Input, ElementRef, AfterViewInit, OnChanges, SimpleChanges, AfterViewChecked} from '@angular/core';

@Directive({
  selector: '[appFocus]'
})
export class FocusDirective implements AfterViewInit, OnChanges, AfterViewChecked {
  constructor(
    private el: ElementRef<any>
  ) { }
  @Input('appFocus') focus: boolean;
  ngAfterViewInit() {
  }
  ngAfterViewChecked() {
    if (this.focus) {
      this.el.nativeElement.focus();
    }
  }
  ngOnChanges(changes: SimpleChanges) {
    console.log(changes);
  }
}
